//
//  CourseCenterCartView.m
//  xpkc
//
//  Created by TopSageOSX on 14/12/22.
//  Copyright (c) 2014年 wanmeizty. All rights reserved.
//

#import "CourseCenterCartView.h"

@implementation CourseCenterCartView

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        //
        [self creatCrouseCenterCartView];
    }
    return self;
}

- (void)creatCrouseCenterCartView{
    self.backgroundColor = [UIColor whiteColor];
    //创建
    UIView *topView = [[UIView alloc]init];
    UIView *mainView = [[UIView alloc]init];
    UIView *bottomView = [[UIView alloc]init];
    
    self.selectAll = [UIButton buttonWithType:UIButtonTypeCustom];
    self.deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    self.cartTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH, SCREEN_HEIGHT-64-60-40) style:UITableViewStylePlain];
    
    UILabel *RMB = [[UILabel alloc]init];
    self.payBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    //位置
    CGRect top_view_frame,main_view_frame,bottom_view_frame;
    CGRect selectall_frame,delete_btn_frame;
    CGRect RMB_label_frame,price_label_frame;
    CGRect pay_btn_frame;
    
    top_view_frame = CGRectMake(0, 0, SCREEN_WIDTH, 40);
    main_view_frame = CGRectMake(0, 40, SCREEN_WIDTH, SCREEN_HEIGHT-64-60-40);
    bottom_view_frame = CGRectMake(0, SCREEN_HEIGHT-60-64, SCREEN_WIDTH, 60);
    selectall_frame = CGRectMake(SCREEN_WIDTH-130, 0, 70, 40);
    delete_btn_frame = CGRectMake(SCREEN_WIDTH-50, 0, 50, 40);
    RMB_label_frame   = CGRectMake(SCREEN_WIDTH*1/2 - 125, 0, 55, 60);
    price_label_frame = CGRectMake(SCREEN_WIDTH*1/2 - 70, 0, 70, 60);
    pay_btn_frame = CGRectMake(SCREEN_WIDTH*2/3, 10, SCREEN_WIDTH/3-10, 40);
    
    topView.frame = top_view_frame;
    bottomView.frame = bottom_view_frame;
    self.selectAll.frame = selectall_frame;
    self.deleteBtn.frame = delete_btn_frame;
    RMB.frame = RMB_label_frame;
    self.totalPrice.frame = price_label_frame;
    self.payBtn.frame = pay_btn_frame;
    
    //详细
    topView.backgroundColor = [UIColor colorWithRed:0.98 green:0.98 blue:0.98 alpha:1];
    topView.layer.shadowColor = [UIColor blackColor].CGColor;
    topView.layer.shadowOffset = CGSizeMake(0, 3);
    topView.layer.shadowOpacity = 0.1;
    
    bottomView.backgroundColor = [UIColor colorWithRed:0.98 green:0.98 blue:0.98 alpha:1];
    bottomView.layer.shadowOffset = CGSizeMake(0, -1);
    bottomView.layer.shadowColor = [UIColor blackColor].CGColor;
    bottomView.layer.shadowOpacity = 0.2;
    
    [self.selectAll setTitle:@"全选" forState:UIControlStateNormal];
    [self.selectAll setTitle:@"取消全选" forState:UIControlStateSelected];
    self.selectAll.titleLabel.font = FONT_SYS_S;
    [self.selectAll setTitleColor:UIColorFromRGB(0xff4e4e) forState:UIControlStateNormal];
    
    [self.deleteBtn setTitle:@"删除" forState:UIControlStateNormal];
    self.deleteBtn.titleLabel.font = FONT_SYS_S;
    [self.deleteBtn setTitleColor:UIColorFromRGB(0xff4e4e) forState:UIControlStateNormal];
    
    RMB.text = @"总计￥:";
    RMB.font = FONT_BOLD(16);
    RMB.textColor = UIColorFromRGB(0xff4e4e);
    
    self.totalPrice = [[NumberView alloc]initWithFrame:price_label_frame];
    self.totalPrice.font = FONT_BOLD(18);
    self.totalPrice.color = OrangeColor;
    
    [self.payBtn setTitle:@"下订单(0)" forState:UIControlStateNormal];
    [self.payBtn setBackgroundColor:UIColorFromRGB(0xff4e4e)];
    self.payBtn.layer.cornerRadius = 3;
    
    //添加
    [self addSubview:self.cartTable];
    
    [topView addSubview:self.selectAll];
    [topView addSubview:self.deleteBtn];
    [self addSubview:topView];
    
    [bottomView addSubview:RMB];
    [bottomView addSubview:self.totalPrice];
    [bottomView addSubview:self.payBtn];
    [self addSubview:bottomView];
}

@end
